<?xml version="1.0" encoding="ISO-8859-1" ?>

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:rich="http://richfaces.org/rich"
	  xmlns:a4j="http://richfaces.org/a4j">


	<body>
	
		<ui:composition template="../templates/template.xhtml">
		
			<ui:define name="title">#{bundle.venda_titulo_consultar}</ui:define>

			<ui:define name="content">
				
				<rich:panel>
					<f:facet name="header">#{bundle.venda_titulo_consultar}</f:facet>
					<a4j:form id="formVendaConsulta">
						
						<h:commandButton action="#{vendaBackBean.obterListaVenda}" value="#{bundle.venda_btn_consultar}" />
						
						<div class="linha"/>
						
						<rich:datascroller for="gridVenda" maxPages="10"/>
						<rich:dataTable value="#{vendaBackBean.vendaFormBean.listaVenda}" var="venda" id="gridVenda" rows="10" align="center" width="100%">
							<rich:column filterBy="#{venda.codigo}">
								<f:facet name="header">
									<h:outputText value="#{bundle.venda_codigo}"/>
								</f:facet>
								<h:outputText value="#{venda.codigo}"/>
							</rich:column>
							<rich:column filterBy="#{venda.nota}">
								<f:facet name="header">
									<h:outputText value="#{bundle.venda_nota} - #{bundle.venda_nota_serie}"/>
								</f:facet>
								<h:outputText value="#{venda.nota} - #{venda.notaSerie}"/>
							</rich:column>
							<rich:column filterBy="#{venda.funcionarioVO.nome}">
								<f:facet name="header">
									<h:outputText value="#{bundle.venda_funcionario}"/>
								</f:facet>
								<h:outputText value="#{venda.funcionarioVO.nome}"/>
							</rich:column>
							<rich:column filterBy="#{venda.clienteVO.nome}">
								<f:facet name="header">
									<h:outputText value="#{bundle.venda_cliente}"/>
								</f:facet>
								<h:outputText value="#{venda.clienteVO.nome}"/>
							</rich:column>
							<rich:column filterBy="#{venda.status}">
								<f:facet name="header">
									<h:outputText value="#{bundle.venda_status}"/>
								</f:facet>
								<h:outputText value="Efetuada" style="color:green;" rendered="#{venda.status == 3}"/>
								<h:outputText value="Cancelada" style="color:red;" rendered="#{venda.status == 5}"/>  
							</rich:column>
							<rich:column>
								<a4j:commandButton id="btnCancelar" actionListener="#{vendaBackBean.listenerIrCancelarVenda}" value="#{bundle.venda_btn_cancelar}" reRender="formVendaManter" disabled="#{venda.status == 5}">
									<f:param id="codigoVendaCancelar" name="codigoVendaCancelar" value="#{venda.codigo}" />
									<rich:componentControl for="manterVenda" attachTo="btnCancelar" operation="show" event="onclick" />
								</a4j:commandButton>
							</rich:column>
							<rich:column>
								<a4j:commandButton id="btnVisualizar" actionListener="#{vendaBackBean.listenerIrVisualizarVenda}" value="#{bundle.venda_btn_visualizar}" reRender="formVendaManter">
									<f:param id="codigoVendaVisualizar" name="codigoVendaVisualizar" value="#{venda.codigo}" />
									<rich:componentControl for="manterVenda" attachTo="btnVisualizar" operation="show" event="onclick" />
								</a4j:commandButton>
							</rich:column>
						</rich:dataTable>
						
						<div class="linha"/>
						
						<a4j:commandButton value="#{bundle.venda_btn_novo}" actionListener="#{vendaBackBean.listenerIrInserirVenda}" id="btnNovo" reRender="formVendaManter">
							<rich:componentControl for="manterVenda" attachTo="btnNovo" operation="show" event="onclick" />
						</a4j:commandButton>
						
					</a4j:form>
				</rich:panel>
				
				<ui:include src="/pages/venda/manterVenda.xhtml" />
				
			</ui:define>
			
		</ui:composition>
		
	</body>

</html>